package com.example.service.impl;

import com.example.model.SpecialtyDish;
import com.example.dao.SpecialtyDishMapper;
import com.example.service.ISpecialtyDishService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Hello
 * @since 2024-07-09
 */
@Service
public class SpecialtyDishServiceImpl extends ServiceImpl<SpecialtyDishMapper, SpecialtyDish> implements ISpecialtyDishService {
    @Autowired
    SpecialtyDishMapper specialtyDishMapper;

    public List<String> getAll(){
        List<SpecialtyDish> specialtyDishList=specialtyDishMapper.selectList(null);
        List<String> imageList=new ArrayList<>();
        for(SpecialtyDish specialtyDish:specialtyDishList){
            String imageStr=specialtyDish.getMenuImage();
            imageStr=imageStr.substring(imageStr.lastIndexOf("/")+1);
            imageStr="../../images/menus_images/"+imageStr+".jpg";
            imageList.add(imageStr);
        }
        System.out.println("Service be called");
        System.out.println(imageList);
        return imageList;
    }
}
